#include "clientwrite.h"

#include <unistd.h>
#include <string.h>
#include <QDebug>

ClientWrite::ClientWrite(QObject *parent)
    : QObject{parent}
{
    m_runningFlag = true;
}

void ClientWrite::writing(int clientFd)
{
    qDebug() << "clientWrite: start write" << clientFd;
    m_clientFd = clientFd;

}

void ClientWrite::sendMyMsg(QString msg)
{
    qDebug() << "clientWrite: ready to send" << msg;
    QByteArray byteArray = msg.toUtf8();
    const char* charArray = byteArray.constData();
    ::write(m_clientFd, charArray, strlen(charArray) + 1);
}

void ClientWrite::stopNow()
{
    m_runningFlag = false;
}
